<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>调查问卷 </title>
</head>
<body>
    <h1>调查问卷 </h1>
    <hr>
<input type="checkbox" id="input1">A
<input type="checkbox" id="input2">B
<input type="checkbox" id="input3">C
<input type="checkbox" id="input4">D<br>
<button onclick="func1()">全选</button>
<button onclick="func2()">全取</button>
<button onclick="func3()">反选</button>
<button onclick="func4()">取值</button>


<script>
    var check = new Array(
        document.getElementById('input1'),
        document.getElementById('input2'),
        document.getElementById('input3'),
        document.getElementById('input4'),

        )
    console.log(check);
    function func1(){
        check[0].checked = 'ture';
        check[1].checked = 'ture';
        check[2].checked = 'ture';
        check[3].checked = 'ture';
    }
    function func2(){
        check[0].checked = 0;
        check[1].checked = 0;
        check[2].checked = 0;
        check[3].checked = 0;
    }
    function func3(){  

        for(var i = 0;i<=3; i++ ){
             check[i].checked = !check[i].checked;
        }      

    }
    function func4(){
        check[0].checked = 'ture';
        check[1].checked = 'ture';
        check[2].checked = 'ture';
        check[3].checked = 'ture';
    }
    
</script>

    

</body>
</html>